package com.ycd.fallback;


import com.ycd.fegin.MovieFeignClient;
import com.ycd.result.JsonResult;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

/**
 * @BelongsProject: springcloud-machinetest
 * @BelongsPackage: cn.itsource.fallback
 * @Author: Director
 * @CreateTime: 2022-09-01  11:28
 * @Description: TODO
 * @Version: 1.0
 */
@Component
public class MovieFeignServiceFallbackFatory implements FallbackFactory<MovieFeignClient> {

    @Override
    public MovieFeignClient create(Throwable throwable) {
        return new MovieFeignClient() {
            @Override
            public JsonResult list() {
                return JsonResult.error("触发熔断，请稍后重试！", "10011");
            }

            @Override
            public JsonResult buyTicket(Long userId, Long movieId) {
                return JsonResult.error("触发熔断，请稍后重试！", "10011");
            }

            @Override
            public JsonResult watchMovie(Long userId, Long movieId) {
                return JsonResult.error("触发熔断，请稍后重试！", "10011");
            }
        };
    }
}
